package com.kaigejava.juc.toolsdemo.countdowlatchdemo;

import java.util.concurrent.CountDownLatch;

/**
 * @author kaigejava
 * 火箭发射倒计时器使用countdownlatch
 */
public class CountdownlatchDemo {
    public static void main(String[] args) {
        CountDownLatch downLatch = new CountDownLatch(5);
        int departmentSize = 5;
        for(int i = 0;i<departmentSize ;i++){
            RocketDepartmCountDowunlatchentThread countDowunlatchentThread = new RocketDepartmCountDowunlatchentThread(""+(i+1),downLatch);
            Thread thread = new Thread(countDowunlatchentThread);
            thread.start();
        }
        //线程等待
        try {
            downLatch.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("==总控室以收到。准备发射~~~");
        System.out.println("====发射====");

    }
}
